import request from '../utils/request'
/**
 * 发布流程
 */
export const uploadStreamAndDeployment = (data: any) => {
  return request({
    url: '/process/definition/uploadStreamAndDeployment',
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data;'
    },
    transformRequest: [
      function () {
        return data
      }
    ]
  })
}

/**
 * 发布流程
 */
export const uploadStringAndDeployment = (data: any) => {
  return request({
    url: '/process/definition/uploadStringAndDeployment',
    method: 'POST',
    data
  })
}

/**
 * 发布流程
 */
export const deployment = (data: any) => {
  return request({
    url: '/process/deployment',
    method: 'POST',
    data
  })
}

/**
 * 获取流程xml文件
 */
export const getProcessXml = (data: any) => {
  return request({
    url: '/process/deployment',
    method: 'POST',
    data
  })
}
/**
 * 获取部署
 */
export const processDefinitionList = (data: any) => {
  return request({
    url: '/process/definition/list',
    method: 'POST',
    data
  })
}
/**
 * 获取流程定义
 */
export const processDefinitionDetail = (id: string) => {
  return request({
    url: `/process/definition/detail/${id}`,
    method: 'GET'
  })
}

/**
 * 获取部署
 */
export const processDeploymentList = (data: any) => {
  return request({
    url: '/process/deployment/list',
    method: 'POST',
    data
  })
}
/**
 * 获取实例
 */
export const processInstanceList = (data: any) => {
  return request({
    url: '/process/instance/list',
    method: 'POST',
    data
  })
}

/**
 * 启动流程实例
 */
export const processInstanceStart = (data: any) => {
  return request({
    url: '/process/instance/start',
    method: 'POST',
    data
  })
}
/**
 * 挂起流程实例
 */
export const processInstanceSuspend = (data: any) => {
  return request({
    url: '/process/instance/suspend',
    method: 'POST',
    data
  })
}

/**
 * 重启流程实例
 */
export const processInstanceResume = (data: any) => {
  return request({
    url: '/process/instance/resume',
    method: 'POST',
    data
  })
}

/**
 * 重启流程实例
 */
export const processInstanceDelete = (data: any) => {
  return request({
    url: '/process/instance/delete',
    method: 'POST',
    data
  })
}

/**
 * 删除部署
 */
export const processDefinitionDelete = (data: any) => {
  return request({
    url: '/process/definition/delete',
    method: 'POST',
    data
  })
}

/**
 * 获取流程实例高亮
 */
export const processInstanceHistoryHighlight = (id: string) => {
  return request({
    url: `/process/instance/history/highlight/${id}`
  })
}
/**
 * 获取流程实例历史
 */
export const processInstanceHistory = (data: any) => {
  return request({
    url: `/process/instance/history/list`,
    method: 'POST',
    data
  })
}
/**
 * 获取待办任务
 */
export const processInstanceTaskList = (data: any) => {
  return request({
    url: '/process/instance/task/list',
    method: 'POST',
    data
  })
}
/**
 * 完成任务
 */
export const processInstanceTaskComplete = (id: string) => {
  return request({
    url: `/process/instance/task/complete/${id}`,
    method: 'POST',
  })
}
/**
 * 获取流程实例历史
 */
export const processInstanceTaskHistory = (data: any) => {
  return request({
    url: '/process/instance/history/userList',
    method: 'POST',
    data
  })
}
